---
export const prerender = false;

if (!Astro.locals.user?.id) return Astro.redirect('/sign-in')
---

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>Home</title>
  </head>
  <body>
    <pre>{JSON.stringify(Astro.locals.user, null, 2)}</pre>
    <button id="signOutButton">Sign Out</button>
    <script>
      import { authClient } from '../lib/auth-client'
      document.getElementById('signOutButton')?.addEventListener('click', async () => {
        await authClient.signOut()
        window.location.href = '/sign-in'
      })
    </script>
  </body>
</html>